package com.casic.ops.utils.pipeline;

import com.casic.ops.entity.domain.pipeline.PipelineNodeInfoDO;
import com.casic.ops.entity.domain.pipeline.PipelineNodeLoggerDO;
import com.casic.ops.entity.dto.pipeline.PipelineNodeInfoDTO;
import com.casic.ops.entity.dto.pipeline.PipelineNodeLoggerDTO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 流水线节点执行记录转换类
 * @author cww
 * @date 2022/6/17
 */
@Component
public class PipelineNodeLoggerConvertor {

    public PipelineNodeLoggerDO toDO(PipelineNodeLoggerDTO pipelineNodeLoggerDTO){
        PipelineNodeLoggerDO pipelineNodeLoggerDO=new PipelineNodeLoggerDO();
        pipelineNodeLoggerDO.setPipelineLoggerUUid(pipelineNodeLoggerDTO.getLoggerUuid());
        pipelineNodeLoggerDO.setCreator(pipelineNodeLoggerDTO.getCreator());
        pipelineNodeLoggerDO.setModifier(pipelineNodeLoggerDTO.getModifier());
        pipelineNodeLoggerDO.setNodeData(pipelineNodeLoggerDTO.getNodeData());
        pipelineNodeLoggerDO.setExecuteEndTime(pipelineNodeLoggerDTO.getExecuteEndTime());
        pipelineNodeLoggerDO.setDeleted(pipelineNodeLoggerDTO.getDeleted());
        pipelineNodeLoggerDO.setGmtCreate(pipelineNodeLoggerDTO.getGmtCreate());
        pipelineNodeLoggerDO.setFinalStatus(pipelineNodeLoggerDTO.getFinalStatus());
        pipelineNodeLoggerDO.setId(pipelineNodeLoggerDTO.getId());
        pipelineNodeLoggerDO.setUuid(pipelineNodeLoggerDTO.getUuid());
        pipelineNodeLoggerDO.setGmtModified(pipelineNodeLoggerDTO.getGmtModified());
        pipelineNodeLoggerDO.setExecuteStartTime(pipelineNodeLoggerDTO.getExecuteStartTime());
        return pipelineNodeLoggerDO;
    }

    public PipelineNodeLoggerDTO toDTO(PipelineNodeLoggerDO pipelineNodeLoggerDO){
        PipelineNodeLoggerDTO pipelineNodeLoggerDTO=new PipelineNodeLoggerDTO();
        pipelineNodeLoggerDTO.setLoggerUuid(pipelineNodeLoggerDO.getPipelineLoggerUUid());
        pipelineNodeLoggerDTO.setCreator(pipelineNodeLoggerDO.getCreator());
        pipelineNodeLoggerDTO.setModifier(pipelineNodeLoggerDO.getModifier());
        pipelineNodeLoggerDTO.setNodeData(pipelineNodeLoggerDO.getNodeData());
        pipelineNodeLoggerDTO.setExecuteEndTime(pipelineNodeLoggerDO.getExecuteEndTime());
        pipelineNodeLoggerDTO.setDeleted(pipelineNodeLoggerDO.getDeleted());
        pipelineNodeLoggerDTO.setGmtCreate(pipelineNodeLoggerDO.getGmtCreate());
        pipelineNodeLoggerDTO.setFinalStatus(pipelineNodeLoggerDO.getFinalStatus());
        pipelineNodeLoggerDTO.setId(pipelineNodeLoggerDO.getId());
        pipelineNodeLoggerDTO.setUuid(pipelineNodeLoggerDO.getUuid());
        pipelineNodeLoggerDTO.setGmtModified(pipelineNodeLoggerDO.getGmtModified());
        pipelineNodeLoggerDTO.setExecuteStartTime(pipelineNodeLoggerDO.getExecuteStartTime());
        return pipelineNodeLoggerDTO;
    }

    public List<PipelineNodeLoggerDTO> toDTOList(List<PipelineNodeLoggerDO> list){
        List<PipelineNodeLoggerDTO> pipelineNodeLoggerDTOList=new ArrayList<>();
        for(PipelineNodeLoggerDO pipelineNodeLoggerDo:list){
            pipelineNodeLoggerDTOList.add(toDTO(pipelineNodeLoggerDo));
        }
        return pipelineNodeLoggerDTOList;
    }

    public List<PipelineNodeLoggerDO> toDOList(List<PipelineNodeLoggerDTO> list){
        List<PipelineNodeLoggerDO> pipelineNodeLoggerDOList=new ArrayList<>();
        for(PipelineNodeLoggerDTO pipelineNodeLoggerDTO:list){
            pipelineNodeLoggerDOList.add(toDO(pipelineNodeLoggerDTO));
        }
        return pipelineNodeLoggerDOList;
    }

}
